package com.wing.productionPlan.controller.admin;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wing.common.enums.Idempotent;
import com.wing.enterprise.feign.EnterpriseClient;
import com.wing.enterprise.product.model.entity.ProcessInfo;

import com.wing.enterprise.product.model.response.ProcessInfoVO;
import com.wing.enterprise.product.model.response.ProductProcessMaterialVO;
import com.wing.productionPlan.model.entity.AuditRecord;
import com.wing.productionPlan.model.entity.ProductionPlanRecord;
import com.wing.productionPlan.model.request.BatchProductionPlanAddForm;
import com.wing.productionPlan.model.request.SubmitProductionPlanOutForm;
import com.wing.productionPlan.model.response.*;
import com.wing.productionPlan.service.*;
import com.wing.web.annotation.RequestObjectFieldIgnore;
import com.wing.common.utils.JsonResult;
import com.wing.common.utils.PageResult;
import com.wing.productionPlan.model.entity.ProductionPlan;
import com.wing.productionPlan.model.request.ProductionPlanForm;
import com.wing.web.utils.JwtUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;


import java.time.LocalDateTime;
import java.util.*;
import java.util.stream.Collectors;

/**
 * @author
 */
@Slf4j
@Validated
@Api(value = "Admin-生产计划管理", tags = "#/productionPlan/productionPlan")
@RestController("productionPlanController")
@RequestMapping("productionPlan/admin/productionPlan")
@RequiredArgsConstructor
public class ProductionPlanController {

    private final ProductionPlanService productionPlanService;
    private final EnterpriseClient enterpriseClient;
    private final ProductionProcessDeviceService productionProcessDeviceService;
    private final QualityTestingRecordDetailService qualityTestingRecordDetailService;
    private final ProductionWorkOrderService productionWorkOrderService;
    private final ProductionProcessService productionProcessService;
    private final AuditRecordService auditRecordService;
    private final ProductionPlanRecordService productionPlanRecordService;

    @ApiOperation(value = "查询所有生产计划", notes = "搜索")
    @GetMapping("/list")
    public PageResult<ProductionPlanVO> list(
            @RequestParam(defaultValue = "1") Integer page
            , @RequestParam(defaultValue = "10") Integer limit
            , @RequestParam(defaultValue = "create_time") String sort
            , @RequestParam(defaultValue = "asc") String order
            , String code
            , String skuCode
            , String skuName
            , String startCreateTime
            , String endCreateTime
            , String orderId
            , String status
            , ProductionPlan.OrderType orderType
            , String planSource
            , String workshopName
            , String skuSpec
            , String startOutputTime
            , String endOutputTime
            , String startShipmentTime
            , String endShipmentTime
    ) {
        Page<ProductionPlan> pg = new Page<>(page, limit);
        Map<String,Object> paramMap = new HashMap();
        //搜索
        if (StringUtils.isNotBlank(code)) {
            paramMap.put("code", code);
        }
        if (StringUtils.isNotBlank(skuCode)) {
            paramMap.put("customerSkuCode", skuCode);
        }
        if (StringUtils.isNotBlank(orderId)) {
            paramMap.put("orderId", orderId);
        }
        if (StringUtils.isNotBlank(skuName)) {
            paramMap.put("customerSkuName", skuName);
        }
        if (StringUtils.isNotBlank(startCreateTime)) {
            paramMap.put("startCreateTime", startCreateTime);
        }
        if (StringUtils.isNotBlank(endCreateTime)) {
            paramMap.put("endCreateTime", endCreateTime);
        }
        if (StringUtils.isNotBlank(status)) {
            Integer value = ProductionPlan.Status.valueOf(status).getValue();
            paramMap.put("status", value);
        }
        if (orderType != null) {
            paramMap.put("orderType", orderType.getValue());
        }
        if (StringUtils.isNotBlank(planSource)) {
            Integer sourceValue = ProductionPlan.PlanSource.valueOf(planSource).getValue();
            paramMap.put("planSource", sourceValue);
        }
        if (StringUtils.isNotBlank(workshopName)) {
            paramMap.put("workshopName", workshopName);
        }
        if (StringUtils.isNotBlank(skuSpec)) {
            paramMap.put("customerSkuSpec", skuSpec);
        }
        if (StringUtils.isNotBlank(startOutputTime)) {
            paramMap.put("startOutputTime", startOutputTime);
        }
        if (StringUtils.isNotBlank(endOutputTime)) {
            paramMap.put("endOutputTime", endOutputTime);
        }
        if (StringUtils.isNotBlank(startShipmentTime)) {
            paramMap.put("startShipmentTime", startShipmentTime);
        }
        if (StringUtils.isNotBlank(endShipmentTime)) {
            paramMap.put("endShipmentTime", endShipmentTime);
        }
        IPage<ProductionPlanVO> list = productionPlanService.pageList4app(pg, paramMap);
        for (ProductionPlanVO item : list.getRecords()) {
            if (item.getCreator().equals(JwtUtils.getLoginUserId())) {
                item.setWhetherEdit(0);
            }
            if (item.getOrderType().equals(ProductionPlan.OrderType.finish)){
                //查询订单id
               String infoCode = this.productionPlanService.getFinishCodeBy(item.getOrderId());
               item.setOrderCode(infoCode);
            }else if(item.getOrderType().equals(ProductionPlan.OrderType.order)){
                String infoCode = this.productionPlanService.getOrderCodeBy(item.getOrderId());
                item.setOrderCode(infoCode);
            }
            //查看
            //已排产总数小于计划生产数才能继续排产
            item.setWhetherProduction(0);
            //查询已排产数量
            QueryWrapper<ProductionPlanRecord> recordQueryWrapper = new QueryWrapper<>();
            recordQueryWrapper.eq("production_plan_id",item.getId());
            recordQueryWrapper.eq("is_deleted",false);
            List<ProductionPlanRecord> records = this.productionPlanRecordService.list(recordQueryWrapper);
            Integer totalQuantity = records.stream()
                    // 过滤掉 productionPlanQuantity 为 null 的对象
                    .filter(product -> product.getProductionPlanQuantity() != null)
                    // 提取出 productionPlanQuantity 并转为 int
                    .mapToInt(ProductionPlanRecord::getProductionPlanQuantity)
                    .sum(); // 进行累加
            item.setProductionPlanHaveQuantity(totalQuantity);
        }
        return new PageResult<>(list.getRecords(), list.getTotal());
    }

    @ApiOperation(value = "查询工序", notes = "搜索")
    @GetMapping("/getProcessInfoPageList")
    public PageResult<ProcessInfoVO> getProcessInfoPageList(
            @RequestParam(defaultValue = "1") Integer page,
            @RequestParam(defaultValue = "100") Integer limit,
            @RequestParam(defaultValue = "create_time") String sort,
            @RequestParam(defaultValue = "asc") String order,
            @RequestParam(value = "productTypeId", required = false) Long productTypeId,
            @RequestParam(value = "code", required = false) String code,
            @RequestParam(value = "name", required = false) String name) {
        PageResult<ProcessInfoVO> pageList = enterpriseClient.getProcessInfoPageList(page, limit, sort, order, productTypeId, code, name);
        return pageList;
    }

    @ApiOperation(value = "查询排产设备", notes = "搜索")
    @GetMapping("/getProductionDeviceByProcessId")
    public PageResult<ProductionProcessDeviceVO> getProductionDeviceByProcessId(
            @RequestParam(value = "processId") Long processId,
            @RequestParam(value = "code", required = false) String code,
            @RequestParam(value = "deviceModel", required = false) String deviceModel,
            @RequestParam(value = "deviceName", required = false) String deviceName,
            @RequestParam(defaultValue = "1") Integer page,
            @RequestParam(defaultValue = "10") Integer limit) {
        Page<ProductionProcessDeviceVO> pg = new Page<>(page, limit);
        IPage<ProductionProcessDeviceVO> list = productionProcessDeviceService.getProductionDeviceByProcessId(pg, processId, code, deviceModel, deviceName);
        return new PageResult<>(list.getRecords(), list.getTotal());
    }

    @ApiOperation(value = "查询工序排产物料", notes = "搜索")
    @GetMapping("/getProcessMaterialPageList")
    public PageResult<ProductProcessMaterialVO> getProcessMaterialPageList(
            @RequestParam(defaultValue = "1") Integer page,
            @RequestParam(defaultValue = "10") Integer limit,
            @RequestParam(defaultValue = "create_time") String sort,
            @RequestParam(defaultValue = "asc") String order,
            @RequestParam(value = "skuCode") String skuCode,
            @RequestParam(value = "processId") Long processId,
            @RequestParam(value = "defaultMaterialSkuCode", required = false) String defaultMaterialSkuCode) {
        PageResult<ProductProcessMaterialVO> pageList = enterpriseClient.getProcessMaterialPageList(page, limit, sort, order, skuCode, processId, defaultMaterialSkuCode);
        return new PageResult<>(pageList.getData(), pageList.getCount());
    }

    @ApiOperation(value = "提交排产计划", notes = "搜索")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "submitProductionPlanOutForm", value = "排产计划数据", dataType = "List", paramType = "query")
    })
    @PostMapping("/submitProductionPlan")
    @Idempotent(keyPrefix = "productionPlanSubmit")
    public JsonResult submitProductionPlan(@RequestBody SubmitProductionPlanOutForm submitProductionPlanOutForm) {
        try {
            productionPlanService.submitProductionPlan(submitProductionPlanOutForm);
            return JsonResult.success("操作成功");
        } catch (Exception e) {
            log.error("submitProductionPlan接口异常，原因是：{} ", e.getMessage(), e);
            return JsonResult.fail("操作失败:" + e.getMessage());
        }
    }

    @ApiOperation(value = "批量(提交生产计划)", notes = "批量-添加")
    @RequestObjectFieldIgnore({"id", "createTime", "remark"})
    @PostMapping("/addBatchPlan")
    @Idempotent(keyPrefix = "addBatchPlan")
    public JsonResult addBatchPlan(@RequestBody BatchProductionPlanAddForm batchProductionPlanAddForm) {
        if (productionPlanService.addBatchPlan(batchProductionPlanAddForm) > 0) {
            return JsonResult.success("添加成功");
        }
        return JsonResult.fail("添加失败");
    }

    @ApiOperation(value = "查询所有工序(提供表格下拉框搜索)", notes = "搜索")
    @GetMapping("/getAllProcessInfo")
    public JsonResult<List<ProcessInfo>> getAllProcessInfo() {
        JsonResult<List<ProcessInfo>> jsonResult = enterpriseClient.getAllProcessInfo();
        return JsonResult.success(jsonResult.getData());
    }

    @ApiOperation(value = "查询机台排产开工单", notes = "搜索")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "page", value = "第几页", defaultValue = "1", example = "1", dataType = "Integer", paramType = "query")
            , @ApiImplicitParam(name = "limit", value = "每页多少条", defaultValue = "10", example = "10", dataType = "Integer", paramType = "query")
            , @ApiImplicitParam(name = "sort", value = "排序字段名", defaultValue = "create_time", example = "create_time", dataType = "String", paramType = "query")
            , @ApiImplicitParam(name = "order", value = "排序规则(asc:正序, desc:倒序)", defaultValue = "asc", example = "asc", dataType = "String", paramType = "query")
            , @ApiImplicitParam(name = "deviceCode", value = "设备编码", dataType = "String", paramType = "query")
    })
    @GetMapping("/getDeviceWorkOrderPageList")
    public PageResult<ProductionWorkOrderVO> getDeviceWorkOrderPageList(
            @RequestParam(defaultValue = "1") Integer page
            , @RequestParam(defaultValue = "10") Integer limit
            , @RequestParam(defaultValue = "create_time") String sort
            , @RequestParam(defaultValue = "asc") String order
            , ProductionWorkOrderVO productionWorkOrderVO) {

        //搜索
        IPage<ProductionWorkOrderVO> pageList = productionWorkOrderService.getProductionWorkOrderVOPageList(productionWorkOrderVO, page, limit);
        return new PageResult<>(pageList.getRecords(), pageList.getTotal());
    }

    @ApiOperation(value = "上移下移开工单", notes = "搜索")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "工单id", dataType = "String", paramType = "query")
            , @ApiImplicitParam(name = "operaType", value = "1:上移 2：下移", dataType = "String", paramType = "query")
    })
    @PutMapping("/moveWorkOrder")
    public JsonResult moveWorkOrder(Long id, Integer operaType) {
        try {
            productionWorkOrderService.moveWorkOrder(id, operaType);
            return JsonResult.success("操作成功");
        } catch (Exception e) {
            log.error("moveWorkOrder接口异常，原因是：{} ", e.getMessage(), e);
            return JsonResult.fail("操作失败:" + e.getMessage());
        }
    }

    @ApiOperation(value = "开工单详情", notes = "搜索")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "工单id", dataType = "Integer", paramType = "query")
            , @ApiImplicitParam(name = "processId", value = "工序id", dataType = "Integer", paramType = "query")
            , @ApiImplicitParam(name = "skuCode", value = "产品编码", dataType = "String", paramType = "query")
            , @ApiImplicitParam(name = "deviceCode", value = "设备编码", dataType = "String", paramType = "query")
    })
    @GetMapping("/getWorkOrderInfo")
    public JsonResult<WorkOrderInfoVO> getWorkOrderInfo(Long id, Long processId, String skuCode, String deviceCode) {
        WorkOrderInfoVO workOrderInfo = productionWorkOrderService.getWorkOrderInfo(id, processId, skuCode, deviceCode);
        return JsonResult.success(workOrderInfo);
    }

    @ApiOperation(value = "工单激活、暂停、关闭接口", notes = "搜索")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "工单id", dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "recordId", value = "排产id(制造令)", dataType = "String", paramType = "query")
            , @ApiImplicitParam(name = "type", value = "0:激活 1：暂停 2:关闭", dataType = "String", paramType = "query")
    })
    @PutMapping("/operationWorkOrder")
    @Idempotent(keyPrefix = "operationWorkOrder")
    public JsonResult operationWorkOrder(Long id,Long recordId,Integer type) {
        try {
            productionWorkOrderService.operationWorkOrder(id,recordId, type);
            return JsonResult.success("操作成功");
        } catch (Exception e) {
            log.error("moveWorkOrder接口异常，原因是：{} ", e.getMessage(), e);
            return JsonResult.fail("操作失败:" + e.getMessage());
        }
    }


    @ApiOperation(value = "查询计划排产明细的工序", notes = "搜索")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "productionPlanId", value = "计划id", dataType = "Long", paramType = "query")
    })
    @GetMapping("/getPlanProductionProcess")
    public JsonResult<List<ProductionProcessVO>> getPlanProductionProcess(
            Long productionPlanId
    ) {
        Map paramMap = new HashMap();
        paramMap.put("productionPlanId", productionPlanId);
        List<ProductionProcessVO> list = productionProcessService.list4app(paramMap);
        //对集合的结果进行去重
        List<ProductionProcessVO> processList = list.stream()
                .collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(ProductionProcessVO::getProcessId))), ArrayList::new));
        return JsonResult.success(processList);
    }

    @ApiOperation(value = "查询工序已排产数量和平均合格率", notes = "搜索")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "processId", value = "工序id", dataType = "Integer", paramType = "query")
            , @ApiImplicitParam(name = "productionPlanId", value = "计划id", dataType = "Integer", paramType = "query")
    })
    @GetMapping("/getProcessOutputAndYield")
    public JsonResult<Map<String, Object>> getProcessOutputAndYield(
            @RequestParam(value = "processId") Long processId
            , @RequestParam(value = "productionPlanId", required = false) Long productionPlanId
    ) {
        return JsonResult.success(qualityTestingRecordDetailService.getProcessOutputAndYield(processId, productionPlanId));
    }

    @ApiOperation(value = "查询计划排产明细工序的设备", notes = "搜索")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "processId", value = "工序id", dataType = "Integer", paramType = "query")
    })
    @GetMapping("/getProcessDeviceByProcessId")
    public JsonResult<List<ProductionProcessDeviceVO>> getProcessDeviceByProcessId(
            @RequestParam(value = "productionPlanId") Long productionPlanId,
            @RequestParam(value = "productionPlanRecordId") Long productionPlanRecordId,
            @RequestParam(value = "processId") Long processId) {
        return JsonResult.success(productionProcessDeviceService.getProcessDeviceByProcessId(productionPlanId, productionPlanRecordId, processId));
    }

    @ApiOperation(value = "选择生产计划", notes = "搜索")
    @GetMapping("/getAllProductionPlan")
    public JsonResult<List<ProductionPlan>> getAllProductionPlan() {
        QueryWrapper<ProductionPlan> wrapper = new QueryWrapper<>();
        wrapper.select("id", "code", "product_type_id", "customer_sku_code");
        List<ProductionPlan> list = productionPlanService.list(wrapper);
        return JsonResult.success(list);
    }

    @ApiOperation(value = "添加生产计划", notes = "添加")
    @RequestObjectFieldIgnore({"id", "createTime", "remark"})
    @PostMapping("/add")
    @Idempotent(keyPrefix = "workOrderPlanAdd")
    public JsonResult add(@Validated(ProductionPlanForm.Add.class) ProductionPlanForm productionPlanForm) {
        if (productionPlanService.add(productionPlanForm) > 0) {
            return JsonResult.success("添加成功");
        }
        return JsonResult.fail("添加失败");
    }

    @ApiOperation(value = "查询生产计划编辑需要的数据详情", notes = "搜索")
    @GetMapping("/getProductionPlanDetails")
    public JsonResult<ProductionPlanVO> getProductionPlanDetails(Long id) {
        ProductionPlanVO planVO = productionPlanService.getProductionPlanDetailById(id);
        if (planVO.getOrderType().equals(ProductionPlan.OrderType.finish)){
            //查询订单id
            String infoCode = this.productionPlanService.getFinishCodeBy(planVO.getOrderId());
            planVO.setOrderCode(infoCode);
        }else if(planVO.getOrderType().equals(ProductionPlan.OrderType.order)){
            String infoCode = this.productionPlanService.getOrderCodeBy(planVO.getOrderId());
            planVO.setOrderCode(infoCode);
        }
        return JsonResult.success(planVO);
    }

    @ApiOperation(value = "作废", notes = "搜索")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "计划id", dataType = "Integer", paramType = "query")

    })
    @PutMapping("/cancellation")
    public JsonResult cancellationPlan(Long id) {
        try {
            productionPlanService.cancellationPlan(id);
            return JsonResult.success("操作成功");
        } catch (Exception e) {
            log.error("cancellation接口异常，原因是：{} ", e.getMessage(), e);
            return JsonResult.fail("操作失败:" + e.getMessage());
        }
    }

    @ApiOperation(value = "修改生产计划", notes = "修改")
    @PutMapping("/update")
    @Idempotent(keyPrefix = "workOrderPlanUpdate")
    public JsonResult update(@RequestBody ProductionPlanForm productionPlanForm) {
        ProductionPlan productionPlan = productionPlanService.getById(productionPlanForm.getId());
        if (productionPlan == null) {
            return JsonResult.fail("修改失败！");
        }
        CopyOptions copyOptions = CopyOptions.create()
                .setEditable(ProductionPlan.class)
                .setIgnoreError(true)
                .setIgnoreNullValue(true);
        BeanUtil.copyProperties(productionPlanForm, productionPlan, copyOptions);
        if (productionPlanService.updateById(productionPlan)) {
            return JsonResult.success("修改成功！");
        }
        return JsonResult.fail("修改失败！");
    }


    @ApiOperation(value = "确认提交", notes = "确认提交")
    @PutMapping("/affirm/{id}")
    @Idempotent(keyPrefix = "workOrderPlanAffirm")
    public JsonResult affirm(@PathVariable("id")Long id) {
        ProductionPlan productionPlan = productionPlanService.getById(id);
        if (productionPlan == null) {
            return JsonResult.fail("修改失败！");
        }
        productionPlan.setStatus(ProductionPlan.Status.affirm);
        productionPlan.setUpdateTime(LocalDateTime.now());
        productionPlan.setModifier(JwtUtils.getLoginUserId());
        productionPlan.setModifierName(JwtUtils.getLoginUsername());
        if (productionPlanService.updateById(productionPlan)) {
            return JsonResult.success("修改成功！");
        }
        return JsonResult.fail("修改失败！");
    }

    @ApiOperation(value = "删除生产计划", notes = "删除")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "productionPlanId", value = "生产计划id", required = true, dataType = "Integer", paramType = "path")
    })
    @DeleteMapping("/{id}")
    public JsonResult delete(@PathVariable("id") Long productionPlanId) {
        if (productionPlanService.removeById(productionPlanId)) {
            return JsonResult.success("删除成功");
        }
        return JsonResult.fail("删除失败");
    }

    @ApiOperation(value = "查询计划数据详情", notes = "搜索")
    @GetMapping("/getProductionPlanInfoById")
    public JsonResult<ProductionPlanDetails> getProductionPlanInfoById(Long id) {
        ProductionPlanDetails productionPlanDetails = new ProductionPlanDetails();
        ArrayList<ProductionPlanVO> planList = new ArrayList<>();
        ProductionPlanVO planVO = productionPlanService.getProductionPlanInfoById(id);
        //查询剩余计划数量
        if (planVO != null && planVO.getOrderId() == null) {
            planVO.setSurplusQuantity(0);
        }

        if (planVO.getPlanSource().getValue() == 0) {
            planVO.setAccessoryList(new ArrayList<String>() {{
                add(planVO.getAccessory());
            }});
        } else if (planVO.getPlanSource().getValue() == 1) {
            //查询订单产品的附件
            List<String> proEnclosure = productionPlanService.getOrderProEnclosure(planVO.getOrderProId());
            planVO.setAccessoryList(proEnclosure);
        }
        planList.add(planVO);
        productionPlanDetails.setPlanSource(planVO.getPlanSource());
        productionPlanDetails.setPlanData(planList);
        Map<String,Object> paramMap = new HashMap<>();
        paramMap.put("businessId", id);
        paramMap.put("type", 0);
        List<AuditRecordVO> list = auditRecordService.list4app(paramMap);
        productionPlanDetails.setAuditData(list);
        return JsonResult.success(productionPlanDetails);
    }

    @ApiOperation(value = "审核生产计划", notes = "修改")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "计划id", dataType = "Integer", paramType = "query")
            , @ApiImplicitParam(name = "remark", value = "审核描述", dataType = "String", paramType = "query")
            , @ApiImplicitParam(name = "checkStatus", value = "审核状态:approve(0,审核通过);reject(1,驳回)", dataType = "String", paramType = "query")
    })
    @PutMapping("/auditPlan")
    @Idempotent(keyPrefix = "workOrderPlanAuditPlan")
    public JsonResult auditPlan(Long id, String remark, AuditRecord.CheckStatus checkStatus) {
        try {
            productionPlanService.auditPlan(id, remark, checkStatus);
            return JsonResult.success("操作成功");
        } catch (Exception e) {
            log.error("auditPlan接口异常，原因是：{} ", e.getMessage(), e);
            return JsonResult.fail("操作失败:" + e.getMessage());
        }
    }


    @ApiOperation(value = "查询剩余数", notes = "查询-剩余")
    @GetMapping("/getQuantityBy/{orderId}/{type}/{productDetailId}")
    public JsonResult getQuantityBy(@PathVariable("orderId") Long orderId,@PathVariable("type")String type,@PathVariable("productDetailId") Long productDetailId) {
        Map<String, Object> map = this.productionPlanService.getQuantityBy(orderId,type,productDetailId);
        return JsonResult.success(map);
    }

}
